package com.sugar.web.servlet;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @标题：Servlet基础类
 * @描述：该类作为大部分Servlet的父类
 * @编写者：杨浩泉
 * @日期：<b>2011-4-19 上午11:42:12</b>
 */
public class BaseHttpServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	protected Log log = LogFactory.getLog(this.getClass()) ;
	
	private ServletContext sc ;

	public ServletContext getSc() {
		return sc;
	}

	public void setSc(ServletContext sc) {
		this.sc = sc;
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response) ;
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}
	
	@Override
	public void init() throws ServletException {
		this.log.info("[....Log4j:]初始化BaseHttpServlet...") ;
		sc = getServletContext() ;
		
		//项目根路径
		sc.setAttribute("path", getServletContext().getContextPath()) ;
		
	}
	
	
	@Override
	public void destroy() {
	}

}
